# Maintainer: George Rawlinson <george@rawlinson.net.nz>
# Contributor: Max Zhao <alcasa dot mz at gmail dot com>
# Contributor: Leonard König <leonard.r.koenig at googlemail dot com>

pkgname=endless-sky
pkgver=0.10.4
pkgrel=1
pkgdesc='A sandbox-style space exploration and combat game'
arch=('loong64' 'x86_64')
url='https://endless-sky.github.io/'
# licenses obtained via following script:
# grep "^License:" copyright | sed -e "s/License: //" -e "s/ /-/" | sort | uniq
license=(
  'GPL3'
  'custom:CC-BY-3.0'
  'custom:CC-BY-4.0'
  'custom:CC-BY-NC-3.0'
  'custom:CC-BY-SA-3.0'
  'custom:CC-BY-SA-4.0'
  'custom:public-domain'
)
depends=(
  'glibc'
  'gcc-libs'
  'openal'
  'libpng'
  'glew'
  'hicolor-icon-theme'
  'libjpeg-turbo'
  'sdl2'
  'libmad'
  'util-linux-libs'
  'libglvnd'
)
makedepends=('git' 'scons')
optdepends=(
  'endless-sky-high-dpi: high resolution graphics assets'
)
_commit='c7874d3e6d8ffde0f46dd2c048c11dc801ab9665'
source=(
  "$pkgname::git+https://github.com/endless-sky/endless-sky#commit=$_commit"
  'fix-binary-install.patch'
)
b2sums=('SKIP'
        'c32e4962ab7ceff081df54a7a1cf3488f57b87aef4533a18b0a8ecafa7a7bea29babeaec4a44767124716c8194d5088444fe17dc238ea05bb22c40e9d591700b')

pkgver() {
  cd "$pkgname"

  git describe --tags --exclude 'continuous' | sed 's/^v//'
}

prepare() {
  cd "$pkgname"

  # binary is installed to /usr/games instead of /usr/bin
  patch -p1 -i "$srcdir/fix-binary-install.patch"
}

build() {
  cd "$pkgname"

  scons -j "$(nproc)"
}

package() {
  cd "$pkgname"

  scons \
    DESTDIR="$pkgdir" \
    PREFIX=/usr \
    install

  # license
  install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" copyright
}
